package nsu.grandfinal;

import java.util.List;

import android.content.Context;
import android.location.Address;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class LocationListAdapter extends ArrayAdapter<Address> {
	private List<Address>	items;
	View									v;
	
	public LocationListAdapter(Context context, int textViewResourceId, List<Address> items) {
		super(context, textViewResourceId, items);
		this.items = items;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.searchlayout2, null);
		}
		int Last = this.getCount();
		if (items != null) ;
		Address addr = (Address) items.get(position);
		Log.i("addr", addr.getAddressLine(0).toString());
		if (addr != null) {
			TextView tv1 = (TextView) v.findViewById(R.id.dataItem01);
			TextView tv2 = (TextView) v.findViewById(R.id.dataItem02);
			TextView tv3 = (TextView) v.findViewById(R.id.dataItem03);
			tv1.setText("이름 : " + addr.getFeatureName());
			tv2.setText("전화번호 : " + addr.getPhone());
			tv3.setText("주소 : " + addr.getAddressLine(0));
		}
		return v;
	}
}